/*
 * File:   Quartic.h
 * Author: jcrada
 *
 * Created on 12 November 2010, 8:49 AM
 */

#ifndef ECB_QUARTIC_H
#define	ECB_QUARTIC_H

#include "ecb/base/Problem.h"

namespace ecb {

    /* Source: (with Random Gaussian noise)
     * @phdthesis{bf:dejong,
         author = {De Jong, Kenneth Alan},
         title = {An analysis of the behavior of a class of genetic adaptive systems.},
         year = {1975},
         publisher = {University of Michigan},
         school={},
         address = {Ann Arbor, MI, USA}}
     */
    class Quartic : public Problem {
    public:
        //Notice that the original Quartic function has Gaussian noise!

        Quartic(const std::string& id = "Quartic", const std::string& name = "Quartic",
                int dimensions = 0, scalar minimum = -1.28, scalar maximum = 1.28,
                bool minimization = true) :
        Problem(id, name, dimensions, minimum, maximum, minimization) { }

        scalar f(const std::vector<scalar>& x) {
            scalar result = 0;
            for (size_t i = 0; i < x.size(); ++i) {
                scalar square = x[i] * x[i];
                scalar square2 = square * square;

                result += (i + 1.0) * square2;
            }
            return result;
        }
    };

}


#endif	/* ECB_QUARTIC_H */

